


<template>
  <el-dialog :title="dialogTitle" :width="dialogWidth" :visible.sync="dialogVisibleComputed" destroy-on-close>
    <el-form label-width="80px" :model="formData" :rules="formRules" ref="formRef">
      <el-form-item label="分类名称" prop="categoryName">
        <el-input placeholder="请输入产品分类名称" v-model="formData.categoryName"></el-input>
      </el-form-item>
      <el-form-item label="显示顺序" prop="orderNum">
        <el-input-number controls-position="right" placeholder="请输入显示顺序" v-model="formData.orderNum"></el-input-number>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input placeholder="请输入内容" type="textarea" :row="8" v-model="formData.remark"></el-input>
      </el-form-item>

      <el-form-item class="dialog-foot">
        <el-button @click="closeDialog">取消</el-button>
        <el-button type="primary" @click="handleConfirm">{{ footname }}</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
export default {
  name:'reusableDialogForm',
  props: {
    footname:String,
    dialogTitle: String,
    dialogWidth: String,
    visible: Boolean,
    formData: Object,
    formRules: Object,
  },
  computed: {
    dialogVisibleComputed: {
      get() {
        return this.visible;
      },
      set(value) {
        this.$emit('update:visible', value);
      },
    },
  },
  methods: {
    closeDialog() {
      this.$emit('update:visible', false);
    },
    handleConfirm() {
      // 在这里执行表单提交或其他逻辑
      // 可以使用 this.formData 获取表单数据
      this.$emit('confirm');
    },
  },
};
</script>

<style lang="less" scoped>
.el-dialog {
    .el-form {
      font-weight: bolder;
    }

    .dialog-foot {
      padding-top: 20px;
      text-align: right;
    }
  }

</style>
